package ${packageName};

import ${basePackageName}entity.base.BoPage;
import org.springframework.web.bind.annotation.*;
import ${basePackageName}entity.${className};
import ${basePackageName}service.${className}Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * @author： xw ftl auto
 * @create： ${.now?string("yyyy-MM-dd HH:mm:ss")}
 */
@RestController
@RequestMapping("/${className?uncap_first}")
public class ${className}Controller {

    @Resource
    private ${className}Service ${className?uncap_first}Service;

    @GetMapping("/page")
    public List<${className}> getAll${className}List() {
        return ${className?uncap_first}Service.list();
    }

    @GetMapping("/{id}")
    public ${className} get${className}ById(@PathVariable Long id) {
        return ${className?uncap_first}Service.getById(id);
    }

    @PostMapping
    public boolean create${className}(@RequestBody ${className} ${className?uncap_first}) {
        return ${className?uncap_first}Service.save(${className?uncap_first});
    }

    @PutMapping("/{id}")
    public boolean update${className}(@PathVariable Long id, @RequestBody ${className} ${className?uncap_first}) {
        ${className?uncap_first}.setId(id);
        return ${className?uncap_first}Service.updateById(${className?uncap_first});
    }

    @DeleteMapping("/{id}")
    public void delete${className}(@PathVariable Long id) {
        ${className?uncap_first}Service.removeById(id);
    }
}
